/******************************************************************************
 * Copyright (C) 2024 EternalChip, Inc.(Gmbh) or its affiliates.
 * 
 * All Rights Reserved.
 * 
 * @file bsp_key.c
 * 
 * @par dependencies 
 * - stdio.h
 * - stdint.h
 * 
 * @author Jack | R&D Dept. | EternalChip 立芯嵌入式
 * 
 * @brief Provide the HAL APIs of AHT21 and corresponding opetions.
 * 
 * Processing flow:
 * 
 * call directly.
 * 
 * @version V1.0 2024-11-25
 *
 * @note 1 tab == 2 spaces!
 * 
 *****************************************************************************/
#ifndef __BAP_KEY_H__
#define __BAP_KEY_H__

//******************************** Includes *********************************//
#include <stdint.h>
#include <stdio.h>

#include "main.h"
#include "usart.h"
#include "stm32f4xx_hal.h"
#include "cmsis_os2.h"

#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"

//******************************** END Includes *****************************//


//******************************** Defines **********************************//
// #define KEY_Pin        GPIO_PIN_0
// #define KEY_GPIO_Port  GPIOA

/*  函数返回状态枚举                    */
typedef enum _key_status_t
{
  KEY_OK                = 0,              /* Operation completed successfully.  */
  KEY_ERROR             = 1,              /* Run-time error without case matched*/
  KEY_ERRORTIMEOUT      = 2,              /* Operation failed with timeout      */
  KEY_ERRORRESOURCE     = 3,              /* Resource not available.            */
  KEY_ERRORPARAMETER    = 4,              /* Parameter error.                   */
  KEY_ERRORNOMEMORY     = 5,              /* Out of memory.                     */
  KEY_ERRORISR          = 6,              /* Not allowed in ISR context         */
  KEY_RESERVED          = 0x7FFFFFFF      /* Reserved                           */
} key_status_t;

typedef enum _key_press_status_t
{
  KEY_PRESSED,
  KEY_RELEASED,
  KEY_DEBOUNCE,
  KEY_LONGPRESS,
  KEY_DOUBLE_PRESSED,
  KEY_PRESS_STATUS_MAX,
} key_press_status_t;
//******************************** END Defines ********************************//

extern xQueueHandle Key_Queue;


//******************************** Declaring ********************************//
key_status_t key_scan(key_press_status_t* key_value);
void Key_Task(void *argument);
//******************************** END Declaring ****************************//
#endif
